package util.exact;

import bean.Task;

import java.util.HashSet;
import java.util.Iterator;

public class IsNeededByTask {
    public static void main(String[] args) {
        //准备测试数据
        //任务数据
        HashSet<String> taskSkills = new HashSet<>();
        taskSkills.add("e1");
        taskSkills.add("e2");
        taskSkills.add("e3");
        Task task = new Task(taskSkills);

        String skill = "e4";
        boolean yesOrNo = isNeededByTask(skill,task);
        System.out.println(yesOrNo);

    }

    /**
     * 此方法用来判断某个技能是否是当前任务所需的
     * @param skill 某个技能
     * @param task 当前任务
     * @return 如果此技能是任务所需则返回true，否则返回false
     */
    public static boolean isNeededByTask(String skill,Task task) {
        Iterator<String> iteratorSkills = task.getSkills().iterator();
        while ( iteratorSkills.hasNext() ) {
            if (iteratorSkills.next() == skill){
                return true;
            }
        }
        return false;
    }
}
